# -*- coding: utf-8 -*-
from src.game.entity.handler import EntityHandler
from src.game.entity.obstacle import EntityObstacle
from src.game.entity.healup import HealUp
from mods.entities.entities import EntityStone, EntitySpawner
from src.handler.sprite import SpriteHandler
from src.helper.path import PathHelper
import pygame

class EntityRegistryHandler:
    
    def handle(self, event):
        EntityHandler.register(EntityStone)
        EntityHandler.register(EntitySpawner)
class SpriteRegistryHandler:
    
    def handle(self, event):
        SpriteHandler.register("stone", PathHelper.getPath('resources', 'sprites', 'stone.png'))  
        SpriteHandler.register("sparkle", PathHelper.getPath('resources','spritesheets', 'sparkle.png'))
        SpriteHandler.register("flame", PathHelper.getPath('resources', 'sprites', 'flame.png')) 
        SpriteHandler.register("flame_ability", PathHelper.getPath('resources', 'sprites', 'flame_ability.png'))
        SpriteHandler.register("blink", PathHelper.getPath('resources', 'sprites', 'blink.png'))
        SpriteHandler.register("placeholder", PathHelper.getPath('resources', 'sprites', 'placeholder.png'))
        SpriteHandler.register("healup", PathHelper.getPath('resources', 'sprites', 'healup.png'))
        
class PlaceObstacle:
    
    def handle(self, client):
        pass
        
    def handleUp(self, client):
        if client.world.player.obstacles > 0:
            client.world.player.obstacles -= 1
            entity = EntityObstacle()
            mx, my = pygame.mouse.get_pos()
            entity.x = mx / 64. + client.window.viewport.x
            entity.y = my / 64. + client.window.viewport.y
            client.world.spawnEntity(entity)
            
class PlaceRegeneration:
    
    def handle(self, client):
        pass
    
    def handleUp(self, client):
        entity = HealUp()
        mx, my = pygame.mouse.get_pos()
        entity.x = mx / 64. + client.window.viewport.x
        entity.y = my / 64. + client.window.viewport.y
        client.world.spawnEntity(entity)
